//
//  tabbar.m
//  自定义tabbar
//
//  Created by Admin on 2017/3/4.
//  Copyright © 2017年 Admin. All rights reserved.
//

#import "tabbar.h"

@implementation tabbar

- (instancetype)init {
    self = [super init];
    if (self) {
        
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    CGFloat buttonW = self.frame.size.width/3;
    CGFloat buttonH = self.frame.size.height;
    CGFloat tabBarButtonY = 0;
    // 按钮索引
    int tabBarButtonIndex = 0;
    for (UIView *subview in self.subviews) {
        if (subview.class != NSClassFromString(@"UITabBarButton")) continue;
        CGFloat tabBarButtonX = tabBarButtonIndex * buttonW;
        subview.frame = CGRectMake(tabBarButtonX, tabBarButtonY, buttonW, buttonH);
        tabBarButtonIndex++;
    }
}
@end
